package com.cloudwise.monitoring_system.controller.clickhouseController;

import com.cloudwise.monitoring_system.entity.MonitorEvent;
import com.cloudwise.monitoring_system.service.clickhouseService.CkMonitorEventService;
import com.cloudwise.monitoring_system.util.Result;
import com.cloudwise.monitoring_system.util.ReturnStatus;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author Reisen
 * @description: 监控告警项controller层
 * @date 2021/6/3 9:29
 */
@Controller
@RequestMapping("ckMonitorEvent")
@ApiOperation("clickhouse告警时间控制器")
public class CkMonitorEventController {
    @Resource
    private CkMonitorEventService ckMonitorEventService;

    /**
     * 查询所有监控告警项
     * @param monitorEvent
     * @return
     */
    @ResponseBody
    @GetMapping("queryAll")
    @ApiOperation("查询所有告警事件")
    public Result queryAll(@ApiParam("告警事件信息")MonitorEvent monitorEvent){
        return new Result(ReturnStatus.SUCCESS.getCode(), ReturnStatus.SUCCESS.getMessage(), 0,
                this.ckMonitorEventService.queryAll(monitorEvent));
    }

    /**
     * 新增监控告警项信息
     * @param monitorEvent
     * @return
     */
    @ResponseBody
    @PostMapping("insert")
    @ApiOperation("新增一条告警事件")
    public Result insert(@ApiParam("告警事件信息")MonitorEvent monitorEvent){
        return new Result(ReturnStatus.SUCCESS.getCode(), ReturnStatus.SUCCESS.getMessage(), 0,
                this.ckMonitorEventService.insert(monitorEvent));
    }

}
